home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / BASIC / LIB / EVENTSHELL / EXTENSION / ShareBan (.txt) < prev   
RISC OS BBC BASIC V Source  |  1995-12-24  |  6KB  |  165 lines

  1.  Module ShareBan
  2.  -----------------------------------------------------------------------
  3.  ShareWare Banner Handling Routines (version 1.01 24-Dec-95)
  4.  This library contains routines that handle the display of a ShareWare
  5.  start up banner to encourage registrations. It uses a 'User' file in
  6.  the application directory and is based on an idea from Graham Crowe
  7.  in the September 1995 Risc User, page 22 but with some cunning
  8.  additions (I would say that wouldn't I). In particular a registration
  9.  number is encoded into the file and a FN is added to the application
  10.  RunImage which must pass the same number back to disable the banner.
  11.  This prevents anybody with a copy of the registration file generator
  12.  from simply creating their own file as they won't know the code number
  13.  in the original file - assuming of course that only the compressed
  14.  version of your program is distributed....
  15.  -----------------------------------------------------------------------
  16.  Structure of Data used in this module
  17.  Public Methods Supported:
  18.    FN_shell_ShareBan_Init                 Initialises module
  19.    FNshell_ShareBan_GetUser
  20.  Responses to events raised by other modules
  21.  Private Methods Supported:
  22.  :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  23.  Public routines..
  24.  :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  25. ("*|Start FN_shell_ShareBan_Init
  26. _shell_ShareBan_Init
  27.  _c_ShareBan_CodeNr% 4
  28. -P_c_ShareBan_ErrNoTemplate$ = "Template file has been corrupted, exiting...."
  29. .._c_ShareBan_BannerName$    = "sharebanner"
  30. 0._m_ShareBan_User$         = "Unregistered"
  31. 1"_m_ShareBan_WindowHandle% = -1
  32. shell_ExReg_ShareBan_Loaded
  33. 7!*|Stop FN_shell_ShareBan_Init
  34. ;)*|Start PROCshell_ShareBan_ShowBanner
  35. shell_ShareBan_ShowBanner
  36.  void%
  37. shell_WindowLoaded( _c_ShareBan_BannerName$ ) 
  38. ShareBan_Registered 
  39. B-    _m_ShareBan_User$ = 
  40. ShareBan_GetUser
  41. ShareBan_OpenWindow
  42. ShareBan_HandleWindow
  43. HY  void%= 
  44. shell_MessageWindow( _c_ShareBan_ErrNoTemplate$, 
  45. shell_GetAppName, "" )
  46. N(*|Stop PROCshell_ShareBan_ShowBanner
  47. R$*|Start FNshell_ShareBan_GetUser
  48. shell_ShareBan_GetUser
  49. = _m_ShareBan_User$
  50. V#*|Stop FNshell_ShareBan_GetUser
  51.  :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  52.  Responses to events raised by other modules..
  53.  :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  54.  :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  55.  Private module routines
  56.  :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  57. j#*|Start PROCShareBan_OpenWindow
  58. ShareBan_OpenWindow
  59. shell_CreateWindowStatic( _c_ShareBan_BannerName$, _m_ShareBan_WindowHandle% )
  60. shell_WindowCentreOnScreen( _m_ShareBan_WindowHandle% )
  61. shell_OpenWindow( _m_ShareBan_WindowHandle%, 
  62.  "Wimp_SetCaretPosition", _m_ShareBan_WindowHandle%, 3, , -1, 0
  63.  "Hourglass_Smash"
  64. shell_MouseLimit( _m_ShareBan_WindowHandle% )
  65.  200,20
  66. u"*|Stop PROCShareBan_OpenWindow
  67. y%*|Start PROCShareBan_HandleWindow
  68. ShareBan_HandleWindow
  69.  reply%, poll_blk%, r%
  70. reply% = 0
  71. -poll_blk% = 
  72. shell_HeapBlockFetch( 2048 )
  73.  "Wimp_Poll", , poll_blk% 
  74. -      reply% = poll_blk%!16:
  75.  mouse click
  76.       
  77.  keypress
  78.       
  79.  poll_blk%!24 
  80.         
  81.  13:reply% = 2
  82.         
  83.  27:reply% = 1
  84.       
  85.  17,18:
  86. A      
  87.  poll_blk%!16 = 0 
  88.  reply% = 1:
  89.  quit message received
  90.  reply%
  91. +poll_blk%!0 = _m_ShareBan_WindowHandle%
  92.  "Wimp_CloseWindow", , poll_blk%
  93. ( "Pointer" )
  94.  reply% = 1 
  95.  "Wimp_CloseDown"
  96. shell_HeapBlockReturn( poll_blk% )
  97. $*|Stop PROCShareBan_HandleWindow
  98. !*|Start FNShareBan_Registered
  99. ShareBan_Registered
  100.  F%, reg%, present%, type%, filelen%
  101.  gap%, testlen%, namelen%
  102. reg% = 
  103. shell_FileExists( 
  104. shell_GetAppDir + ".User" ) 
  105. >  type%    = 
  106. shell_FileType( 
  107. shell_GetAppDir + ".User" )
  108. @  filelen% = 
  109. shell_FileLength( 
  110. shell_GetAppDir + ".User" )
  111. *  F% = 
  112. shell_GetAppDir + ".User" )
  113.   namelen% = 
  114.   gap%     = 
  115.   void%    = 
  116.   void%    = 
  117.   void%    = 
  118.   void%    = 
  119. 7  testlen% = ( gap% + 1 ) * namelen% + 2 + gap% + 4
  120.  type% <> &FFD 
  121.  testlen% <> filelen% 
  122.     reg% = 
  123. +  _m_ShareBan_User$ = 
  124. ShareBan_GetUser
  125. shell_GetProgramCodeNr 
  126.  1000 ) <> !_c_ShareBan_CodeNr% 
  127. *    _m_ShareBan_User$ = "Unregistered"
  128.     reg% = 
  129.     reg% = 
  130.   reg% = 
  131. = reg%
  132.  *|Stop FNShareBan_Registered
  133. *|Start FNShareBan_GetUser
  134. ShareBan_GetUser
  135.  J%, count%, asc%, user$, len%, gap%, file_handle%
  136. 2file_handle% = 
  137. shell_GetAppDir + ".User" )
  138. len% = 
  139. # file_handle%
  140. gap% = 
  141. # file_handle%
  142. +_c_ShareBan_CodeNr%?0 = 
  143. # file_handle%
  144. +_c_ShareBan_CodeNr%?1 = 
  145. # file_handle%
  146. +_c_ShareBan_CodeNr%?2 = 
  147. # file_handle%
  148. +_c_ShareBan_CodeNr%?3 = 
  149. # file_handle%
  150. user$ = ""
  151. count% = 1
  152.  J% = 1 
  153.  gap%
  154.     asc% = 
  155. # file_handle%
  156.   asc% = 
  157. # file_handle%
  158.   user$ += 
  159. ( asc% )
  160.   count% += 1
  161.  count% > len%
  162. # file_handle%
  163. = user$
  164. *|Stop FNShareBan_GetUser
  165.